<?php
namespace home\controller;
use framework\core\Controller;
use framework\core\Factory;

class LoginController extends Controller{
    //显示登录页面
    public function indexAction(){
        $this->smarty->left_delimiter="<{";
        $this->smarty->right_delimiter="}>";
        $this->smarty->display("login/login.html");
    }
    //接受登录的表单
    public function loginAction(){
        $data=$_POST['username'];
        $pass=$_POST['password'];
        $model=Factory::M('LoginModel');
        $result=$model->login($data);
        if ($result){
            $res=$model->password($pass);
            if ($res){
                $this->jump("登录成功，即将自动登陆",'index.php?m=home&a=index&c=category');
            }else{
                $this->jump("密码不正确！",'index.php?m=home&a=index&c=login');
            }
        }else{
            $this->jump("用户名不存在！请先注册",'index.php?m=home&a=index&c=login');
        }
    }
}